home *** CD-ROM | disk | FTP | other *** search
- Path: news.tte.vtt.fi!newsmaster
- From: Ali Lattunen <Ali.Lattunen@vtt.fi>
- Newsgroups: comp.lang.c++
- Subject: Strange template behavior with Borland C++
- Date: 30 Jan 1996 07:35:21 GMT
- Organization: VTT Information Technology
- Message-ID: <4ekhnp$6pe@hemuli.tte.vtt.fi>
- NNTP-Posting-Host: tte2053.tte.vtt.fi
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.2N (Windows; I; 16bit)
-
-
- Hello all!
-
- Has anyone else had problems with using templates with Borland C++ 4.5x
- compiler? I still haven't got the idea of how templates are treated by
- the compiler.
-
- I have done everything according to the rules mentioned in the manuals:
- included both my template class declarations and member function
- implementations in the header files and compiled the whole project using
- the -Jg switch (smart templates).
-
- However, the compiler is able to create only one instance of each member
- function. The link-time error occurs if member functions of several types
- of template classes are called.
-
- If I have, for example, template class TemplClass<class T> with member
- function TemplClass<T>::Foo(), and have template instancies
- TemplClass<MyClass1> C1 and TemplClass<MyClass2> C2, calling foo as
- C1.Foo() works fine. But the C2.Foo() causes a linker error:
-
- Undefined symbol TempClass<MyClass2>::Foo() in module...
-
- What the heck? The problem is avoided if Foo is defined inline!?
- But why? What is the point in this?
-
- ---------------------------------------------
- Ali Lattunen
- VTT Information Tecnology
- Telecommunications
- Otakaari 7 B, Espoo, P.O. Box 1202
- FIN-02044 VTT
- Finland
-
- phone: +358 0 456 6482
- fax: +358 0 456 7013
- email: Ali.Lattunen@vtt.fi
- ---------------------------------------------
-
-